package com.xh.one2one.lesson.service.impl;

import com.xh.one2one.lesson.bean.request.LessonAuditCommentRequest;
import com.xh.one2one.lesson.model.LessonAuditComment;
import com.xh.one2one.lesson.dao.LessonAuditCommentMapper;
import com.xh.one2one.lesson.service.ILessonAuditCommentService;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.core.bean.XhPage;
import com.xh.core.util.StringUtils;
import java.util.List;
/**
 * <p>
 * 备课审核评价 服务实现类
 * </p>
 *
 * @author TW
 * @since 2021-04-22
 */
@Service
public class LessonAuditCommentServiceImpl extends BaseServiceImpl<LessonAuditCommentMapper, LessonAuditComment> implements ILessonAuditCommentService {
    @Override
    public XhPage queryLessonAuditCommentPage(XhPage page, LessonAuditCommentRequest bean) {
        QueryWrapper qw=new QueryWrapper<LessonAuditComment>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return (XhPage) this.dao.selectPage(page,qw);
    }

    @Override
    public LessonAuditComment queryComment(LessonAuditCommentRequest bean) {
        QueryWrapper qw=new QueryWrapper<LessonAuditComment>();
        //拼装条件
        qw=prepareParams(bean, qw);
        return this.dao.selectOne(qw);
    }

    @Override
    public List queryLessonAuditComment(LessonAuditCommentRequest bean) {
        QueryWrapper qw=new QueryWrapper<LessonAuditComment>();
        //拼装条件
        qw=prepareParams(bean, qw);

        return this.dao.selectList(qw);
    }

    /**
     * 准备条件
     * @param bean
     * @param qw
     */
    private QueryWrapper prepareParams(LessonAuditCommentRequest bean, QueryWrapper qw) {
        if(bean.getIds()!=null&&bean.getIds().length>0){
            qw.in("id",bean.getIds());
        }
        if(!StringUtils.isEmpty(bean.getAuditId())){
            qw.eq("audit_id",bean.getAuditId());
        }
        return qw;
    }
}
